home *** CD-ROM | disk | FTP | other *** search
- /* Program 51 */
- /*
- For a more complete sample expert system, see
- the program GENI.PRO on the LIBRARY DISK
- */
- database
- xpositive(symbol,symbol)
- xnegative(symbol,symbol)
-
- predicates
- run
- animal_is(symbol)
- it_is(symbol)
- positive(symbol,symbol)
- negative(symbol,symbol)
- clear_facts
- remember(symbol,symbol,symbol)
- ask(symbol,symbol)
-
- goal
- run.
-
- clauses
- run:-
- animal_is(X),!,
- write("\nYour animal may be a(n) ",X),
- nl,nl,clear_facts.
-
- run:-
- write("\nUnable to determine what"),
- write(" your animal is. \n\n"),clear_facts.
-
- positive(X,Y) if xpositive(X,Y),!.
- positive(X,Y) if not(negative(X,Y)),! and ask(X,Y).
- negative(X,Y) if xnegative(X,Y),!.
-
- ask(X,Y):-
- write(X," it ",Y,"\n"),
- readln(Reply),
- remember(X,Y,Reply).
-
- remember(X,Y,yes):-
- asserta(xpositive(X,Y)).
-
- remember(X,Y,no):-
- asserta(xnegative(X,Y)),
- fail.
-
- clear_facts:-
- retract(xpositive(_,_)),fail.
-
- clear_facts:-
- retract(xnegative(_,_)),fail.
-
- clear_facts:-
- write("\n\nPlease press the space bar to Exit"),
- readchar(_).
-
- animal_is(cheetah) if
- it_is(mammal),
- it_is(carnivore),
- positive(has,tawny_color),
- positive(has,black_spots),!.
-
- animal_is(tiger) if
- it_is(mammal) and
- it_is(carnivore) and
- positive(has,tawny_color) and
- positive(has,black_stripes),!.
-
- animal_is(giraffe) if
- it_is(ungulate) and
- positive(has,long_neck) and
- positive(has,long_legs) and
- positive(has,dark_spots),!.
-
- animal_is(zebra) if
- it_is(ungulate) and
- positive(has,black_stripes),!.
-
- animal_is(ostrich) if
- it_is(bird) and
- not(positive(does,fly)) and
- positive(has,long_neck) and
- positive(has,long_legs),!.
-
- animal_is(penguin) if
- it_is(bird) and
- not(positive(does,fly)) and
- positive(does,swim) and
- positive(has,black_and_white_color),!.
-
- animal_is(albatross) if
- it_is(bird) and
- positive(does,fly),
- positive(does,fly_well),!.
-
- it_is(mammal) if
- positive(has,hair),
- positive(does,give_milk),!.
-
- it_is(carnivore) if
- it_is(mammal),
- positive(does,eat_meat),
- positive(has,pointed_teeth),
- positive(has,claws),!.
-
- it_is(ungulate) if
- it_is(mammal),
- positive(has,hooves),
- positive(does,chew_cud),!.
-
- it_is(bird) if
- not(positive(has,hair)),
- not(positive(does,give_milk)),
- positive(has,feathers),
- positive(does,lay_eggs),!.
-